﻿using Summer.IO;
using System.Xml.Serialization;

#region License
/*
 *  Copyright (c) Dumuzi.cn 2009 , All rights reserved.
 *  CLR Version: 2.0.50727.4927
 *  NameSpace: Summer.Core.Config
 *  Author:Edwin Tai,戴佳顺
 *  Msn:edwin19861218@hotmail.com
 *  QQ: 1961218
 *  Date:2009-11-06 18:09:08
 *  Licensed under the Microsoft Public License (Ms-PL)
 *  This license governs use of the accompanying software. 
 *  If you use the software, you accept this license.
 *  If you do not accept the license, do not use the software.
 */
#endregion

namespace Summer.Core.Config
{
    public partial class SummerConfig : IParseableFile
    {
        [XmlElement(ElementName = "ioc")]
        public Ioc IocConfig
        {
            get;
            set;
        }
        public class Ioc
        {
            [XmlElement(ElementName = "root")]
            public RootContainer Root
            {
                get;
                set;
            }

            [XmlElement(ElementName = "containers")]
            public ContainerCollection Containers
            {
                get;
                set;
            }
            [XmlElement(ElementName = "contexts")]
            public ContextsCollection Contexts
            {
                get;
                set;
            }

            public class RootContainer
            {
                [XmlAttribute(AttributeName = "class")]
                public string Class
                {
                    get;
                    set;
                }
            }

            public class ContainerCollection
            {
                [XmlElement(ElementName = "object")]
                public ContextObject[] Objects
                {
                    get;
                    set;
                }

            }

            public  class ContextObject
            {
                public ContextObject() { Singleton = true; }

                [XmlAttribute(AttributeName = "name")]
                public string Name
                {
                    get;
                    set;
                }
                [XmlAttribute(AttributeName = "class")]
                public string Class
                {
                    get;
                    set;
                }
                [XmlAttribute(AttributeName = "ref")]
                public string Ref
                {
                    get;
                    set;
                }
                [XmlElement(ElementName = "property")]
                public Property[] Properties
                {
                    get;
                    set;
                }
                [XmlAttribute(AttributeName = "singleton")]
                public bool Singleton
                {
                    get;
                    set;
                }


            }

            public class Property
            {
                [XmlAttribute(AttributeName = "name")]
                public string Name
                {
                    get;
                    set;
                }
                [XmlAttribute(AttributeName = "value")]
                public string Value
                {
                    get;
                    set;
                }
                [XmlElement(ElementName = "list")]
                public PropertyArray List
                {
                    get;
                    set;
                }
                [XmlElement(ElementName = "map")]
                public PropertyDictionary Map
                {
                    get;
                    set;
                }
                /*
                [XmlElement(ElementName = "list")]
                public List<string> Lists
                {
                    get;
                    set;
                }
                [XmlElement(ElementName = "map")]
                public IDictionary<string,string> Maps
                {
                    get;
                    set;
                }
                 * */
            }
            public class PropertyArray
            {
                [XmlAttribute(AttributeName = "value")]
                public string Value
                {
                    get;
                    set;
                }
            }
            public class PropertyDictionary
            {
                [XmlAttribute(AttributeName = "name")]
                public string Name
                {
                    get;
                    set;
                }
                [XmlAttribute(AttributeName = "value")]
                public string Value
                {
                    get;
                    set;
                }
            }

            public class ContextsCollection
            {
                [XmlElement(ElementName = "context")]
                public Context[] ContextArray
                {
                    get;
                    set;
                }
            }

            public class Context
            {
                [XmlAttribute(AttributeName = "name")]
                public string Name
                {
                    get;
                    set;
                }
                [XmlElement(ElementName = "object")]
                public ContextObject[] Objects
                {
                    set;
                    get;
                }

            }
        }

    }
}
